package com.ruoyi.app.controller.business.audit;

import com.ruoyi.business.base.PageParam;
import com.ruoyi.business.order.domain.JbPaymentReceived;
import com.ruoyi.business.order.domain.vo.JbPaymentReceivedVO;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.controller.business.order.factory.JbPaymentReceivedFactory;
import com.ruoyi.web.core.JoController;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * APP 退款 Controller
 *
 * @author Jyl
 */
@RestController
@RequestMapping("/app/payment_received")
public class AppPaymentReceivedController extends JoController
{

    private static final Logger log = LoggerFactory.getLogger(AppPaymentReceivedController.class);

    @Autowired
    private JbPaymentReceivedFactory jbPaymentReceivedFactory;

    @ApiOperation("查询退款列表")
    @GetMapping("/list")
    public TableDataInfo list(PageParam page, JbPaymentReceivedVO jbPaymentReceivedVO)
    {
        return getDataTable(jbPaymentReceivedFactory.list(page, jbPaymentReceivedVO));
    }

    @ApiOperation("新增回款")
    @Log(title = "回款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JbPaymentReceived jbPaymentReceived)
    {
        return toAjax(jbPaymentReceivedFactory.add(jbPaymentReceived));
    }

    @ApiOperation("修改回款")
    @Log(title = "回款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JbPaymentReceived jbPaymentReceived)
    {
        return toAjax(jbPaymentReceivedFactory.edit(jbPaymentReceived));
    }

    @ApiOperation("获取回款详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jbPaymentReceivedFactory.getById(id));
    }

    @ApiOperation("删除回款")
    @Log(title = "回款", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jbPaymentReceivedFactory.remove(ids));
    }
}
